#ifndef _MODBUS_USER_H__
#define _MODBUS_USER_H__

#include "config.h"
#include "queue.h"
#include "uart_drv.h"

#define UNIT_SIZE    sizeof(unitList) / sizeof(uint16_t)
#define REG_SIZE    sizeof(MB_00)   / sizeof(uint16_t) 

typedef struct
{    
	uint16_t  Button;
    uint16_t  CB1;
    uint16_t  CB2;
    uint16_t  CB3;
    uint16_t  CB4;
    uint16_t  CB5;
    uint16_t  CB6;
    uint16_t  Test;
}RegData_t;
typedef struct 
{
    uint16_t reg1;
    uint16_t reg2;
    uint16_t reg3;
    uint16_t reg4;
    uint16_t reg5;
    uint16_t reg6;
}MyData;

// Modbus异常代码
typedef enum {
    MODBUS_EX_NONE = 0,
    MODBUS_EX_ILLEGAL_FUNCTION = 1,
    MODBUS_EX_ILLEGAL_ADDRESS = 2,
    MODBUS_EX_ILLEGAL_VALUE = 3,
    MODBUS_EX_SLAVE_FAILURE = 4
} ModbusException;

void ModbusInit(void);
void ModbusMasterProcess(void);
uint16_t modbus_crc16( uint8_t *dat, uint16_t len);

extern RegData_t      MB_00;
extern MasterUnit unitList[];
#endif /* _MODBUS_USER_H__ */
